package br.com.audasi.audasiservices.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import br.com.audasi.audasiservices.dao.OrdemServicoRepository;
import br.com.audasi.audasiservices.model.OrdemServico;

@Controller
public class OrdemServicoController {

	@Autowired
	private OrdemServicoRepository repository;

	private OrdemServico ordemServico = new OrdemServico("1");

	@RequestMapping("/salvaOS")
	public String salvar(@RequestParam("numero") String numero,
			@RequestParam("abertura") String abertura) {

		ordemServico.setNumero(numero);
		ordemServico.setAbertura(abertura);
		repository.save(ordemServico);

		return "redirect:/";

	}
}
